package com.hopkinscsc.windows;

import java.awt.Graphics;

public abstract class Element {
	private int x, y, dx, dy;
	private boolean fill = true;
	
	public Element(int x, int y, int dx, int dy){
		this.x 		= x;
		this.y 		= y;
		this.dx     = dx;
		this.dy     = dy;
	}
	/**
	 * This sets the elements current x value
	 * @param x the value that you would like the x to be
	 */
	public void setX(int x){
		this.x = x;
	}
	/**
	 * This sets the elements current y value
	 * @param y the value that you would like the y to be
	 */
	public void setY(int y){
		this.y = y;
	}
	/**
	 * This sets how many pixels the element will move left or right each frame
	 * @param dx the number of pixels to move. Positive for right, negative for left
	 */
	public void setXMovement(int dx){
		this.dx = dx;
	}
	/**
	 * This sets how many pixels the element will move up or down each frame
	 * @param dy the number of pixels to move. Positive for down, negative for up
	 */
	public void setYMovement(int dy){
		this.dy = dy;
	}
	
	/**
	 * This gets the current x value of the element
	 * @return an integer the elements x
	 */
	public int getX(){
		return x;
	}
	/**
	 * This gets the current y value of the element
	 * @return an integer the elements y
	 */
	public int getY(){
		return y;
	}
	/**
	 * This gets the current directional x value of the element
	 * @return an integer the elements dx
	 */
	public int getDx(){
		return dx;
	}
	/**
	 * This gets the current directional y value of the element
	 * @return an integer the elements dy
	 */
	public int getDy(){
		return dy;
	}
	/**
	 * Adds the dx and dy values the the x and y values
	 * Should only be called by the engine
	 * should be called every frame 
	 */
	public void update(){
		x += dx;
		y += dy;
	}
	/**
	 * Changes the inside of the rectangle to a color or blank
	 * @param value true if you want the element to be filled inside, false if you dont
	 */
	public void fill(boolean value){
		this.fill = value;
	}
	/**
	 * Gets the current fill value
	 * @return true if the element is being filled otherwise false
	 */
	public boolean fill(){
		return this.fill;
	}
	/**
	 * Moves the element to a new position. Quicker than setX or Y if you want to do both
	 * @param x the new x position
	 * @param y the new y position
	 */
	public void move(int x, int y){
		this.x = x;
		this.y = y;
	}
	abstract void draw(Graphics g);
}
